<template>
  <header class="header">
    <h1>todos</h1>
    <input id="toggle-all" class="toggle-all" v-model="isAll" type="checkbox" >
    <label for="toggle-all"></label>
    <input
    v-model="task"
      @keydown.enter="add1"
      class="new-todo"
      placeholder="输入任务名称-回车确认"
      autofocus
    />
  </header>
</template>

<script>
export default {
  computed:{
isAll:{
  set(val){
return this.list.filter(item=>item.isDone=val)
  },
  get(){
    return this.list.every(item=>item.isDone)  }
}
  },
  props:['list'],
  data () {
    return {
      task:''
    }
  },
 methods:{
  add1(){
if(this.task.trim()===''){
  return alert('请输入正确内容')
}
this.$emit('addT',this.task)
this.task=''
  }
 }
}
</script>